<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>账户信息</title>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/app.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"><span>返回</span></a>
			<a class="mui-icon mui-icon-checkmarkempty mui-pull-right" id="submit"></a>
			<h1 class="mui-title" id="title">修改密码</h1>
		</header>
		<div class="mui-content">
			<div class="mui-input-group">
				<div class="mui-input-row">
					<input type="password" id="oldpwd" name="oldpwd" placeholder="旧密码" class="mui-input-password">
				</div>
			</div>
			<div class="mui-input-group" style="margin-top: 15px;">
				<div class="mui-input-row">
					<input type="password" id="newpwd" name="newpwd" placeholder="新密码" class="mui-input-password">
				</div>
				<div class="mui-input-row">
					<input type="password" id="confirmpwd" name="confirmpwd" placeholder="确认密码" class="mui-input-password">
				</div>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../js/mui-extend.js" ></script>
		<script type="text/javascript" src="../../js/app.js" ></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			mui.plusReady(function() {
				var current = plus.webview.currentWebview();
				showPage(current);
				mui(".mui-bar-nav").on("tap", "#submit", function(e) {
					var att = plus.webview.currentWebview().attribute;
					var oldpwd = document.getElementById("oldpwd").value;
					var newpwd = document.getElementById("newpwd").value;
					//未修改不提交
					if (newpwd.length < 6) {
						mui.toast('密码长度需要大于六个字符');
						return;
					}
					if (newpwd == oldpwd) {
						mui.toast('您没有更新数据');
						return;
					}
					if (newpwd != document.getElementById("confirmpwd").value) {
						mui.toast('您两次输入的密码不一致');
						return;
					} else {
						user.setpwd(oldpwd, newpwd, function(data) {
							//console.log(data);
							if (data == 200) {
								//修改成功退出登录
								var Username = persistent.uinfo().Telephone;
								cache("uid",null);
								cache("utoken",null);
								cache("uinfo",null);
								cache('lastUser', Username);
								mui.fire(plus.webview.getLaunchWebview(), 'relogin');
								mui.back();
							} else {
								mui.toast("Error:");
							}
						});
					}
				});
			});
		</script>
	</body>

</html>